class AbsClass {
    test() {
        throw "未实现";
    }
}


const classList = [];

{
    class ClassImpl extends AbsClass {
        test() {
            console.log("1111")
        }
    }

    const key = 1;
    const index = classList.findIndex((e) => e["key"] === key);
    const impl = new ClassImpl();
    const item = {
        "key": key,
        "value": impl
    };
    if (index === -1) {
        classList.push(item);
    } else {
        classList[index] = item;
    }
}

{
    class ClassImpl extends AbsClass {
        test() {
            console.log("22222")
        }
    }

    const key = 2;
    const index = classList.findIndex((e) => e["key"] === key);
    const impl = new ClassImpl();
    const item = {
        "key": key,
        "value": impl
    };
    if (index === -1) {
        classList.push(item);
    } else {
        classList[index] = item;
    }
}


{
    class ClassImpl extends AbsClass {
        test() {
            console.log("3333")
        }
    }

    const key = 3;
    const index = classList.findIndex((e) => e["key"] === key);
    const impl = new ClassImpl();
    const item = {
        "key": key,
        "value": impl
    };
    if (index === -1) {
        classList.push(item);
    } else {
        classList[index] = item;
    }
}

function getClass(key) {
    const index = classList.findIndex((e) => e["key"] === key);
    if (index === -1) {
        throw `找不到实现类,key: ${key}`;
    }
    return classList[index]["value"];
}

/**
 *
 * @param {Array<string>} json
 */
function a(json) {

}


getClass(3).test();

getClass(4).test();

